{extend name="public:base" /}
{block name="title"}{$site_title}{/block}
{block name="content"}
<script type="text/javascript" src="_EDITOR_/wangEditor.min.js"></script>
<!--/sidebar-->

<div class="main-wrap">
    <div class="crumb-wrap">
        <div class="crumb-list">
            <i class="icon-font"></i>
            <a href="/baibu/admin/Index">首页</a>
            <span class="crumb-step">&gt;</span>
            <a class="crumb-name" href="/baibu/admin/Article/">文章中心</a>
            <span class="crumb-step">&gt;</span>
            <span>{$nav}</span>
        </div>
    </div>
    <div class="result-wrap">
        <div class="result-content">
            <form action="{$url}" method="post" id="myform" name="myform" enctype="multipart/form-data">
                <table class="insert-tab" width="100%">
                    <tbody>
                    <tr>
                        <th width="120">
                            <i class="require-red">*</i>标题：
                        </th>
                        <td>
                            <input class="common-text required" name="article_title" size="50" value="{$info.article_title|default=''}" type="text">
                        </td>
                    </tr>
                    <tr>
                        <th width="120">
                            <i class="require-red">*</i>作者：
                        </th>
                        <td>
                            <input class="common-text required" name="article_author" size="50" value="{$info.article_author|default='xxxxx'}" type="text">
                        </td>
                    </tr>
                    <tr>
                        <th>摘要：</th>
                        <td>
                            <textarea name="article_abstract" class="common-textarea" style="width:44%;margin-top: 1%;"  rows="5">{$info.article_abstract|default=''}</textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>内容：</th>
                        <td>
                            <div id="editor" style="width: 45%;">
                            {$info.article_content|default=''}
                            </div>

                        </td>
                    </tr>
                    <tr>
                        <th>
                            <i class="require-red">*</i>选择分类：
                        </th>
                        <td>
                            <select name="article_category_id" style="width:120px;height: 30px;border: 1px #ccc solid;border-radius: 5px;padding: 4px;font-size: 14px;font-family:'Arial';background: #fff;color: #555;box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);">

                                {if isset($info.article_category_id)}
                                {volist name='cate' id='vo'}
                                <option value="{$vo.article_cate_id}" {if $info.article_category_id== $vo.article_cate_id}selected{/if}>{$vo.article_cate_name}</option>
                                    {volist name="vo['child']" id="child"}
                                    <option value="{$child.article_cate_id}" {if $info.article_category_id== $child.article_cate_id}selected{/if}>&nbsp;&nbsp;├&nbsp;{$child.article_cate_name}</option>
                                    {/volist}
                                {/volist}
                                {else /}
                                    {volist name='cate' id='vo'}
                                    <option value="{$vo.article_cate_id}">{$vo.article_cate_name}</option>
                                        {volist name="vo['child']" id="child"}
                                        <option value="{$child.article_cate_id}">&nbsp;&nbsp;├&nbsp;{$child.article_cate_name}</option>
                                        {/volist}
                                    {/volist}
                                {/if}
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>状态：</th>
                        <td>
                            {if isset($info.article_status)}
                            <input class="mui-switch mui-switch-anim" type="checkbox" {if $info.article_status ==1}checked{/if}>
                            {else /}
                            <input class="mui-switch mui-switch-anim" type="checkbox" >
                            {/if}
                            <input class="s" type="hidden" value="{$info.article_status|default=''}" name="article_status">
                            <input type="hidden" value="{$info.article_id|default=''}" name="article_id">
                            <input type="hidden" value="" name="article_content">
                        </td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input id="sub" class="btn btn-primary btn6 mr10" value="提交" type="button">
                            <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
<!--/main-->
{/block}
{block name="js"}
<!--<script type="text/javascript" src="_EDITOR_/wangEditor.min.js"></script>-->
<script>
    //加载编辑器
    var E = window.wangEditor;
    var editor = new E('#editor');
    editor.customConfig.uploadImgShowBase64 = 'true';
    editor.create();
    $(function () {
        if(!$('.s').val()){
            $('.s').val(0);
        }
        $('.mui-switch-anim').click(function () {
            if($(this).prop("checked")){
                $('.s').val(1);
            }else{
                $('.s').val(0);
            }
        });

        $('#sub').click(function(){
            var html = $('.w-e-text').html();
            if(html =='<p><br></p>'){
                layer.msg('内容不能为空', {icon: 5,time:1200});
                    return;
            }
            $('input[name=article_content]').val(html);

            if($('input[name=article_title]').val() == ''){
                layer.msg('标题不能为空', {icon: 5,time:1200});
                return;
            }
            var url = $('form').attr('action');
            $.ajax({
                url : url,
                dataType : "json",
                type : "post",
                data : $('form').serialize(),
                success :function (data) {
                    if(data.status){
                        layer.msg(data.msg,{icon:1,time:1200,end:function () {
                                location.href=data.data;
                            }});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1200});
                    }
                }
            });
        });
    });
</script>
{/block}